package org.edu.modules.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import java.util.Map;
import org.edu.modules.course.entity.VeCuzCourse;
import org.edu.modules.course.mapper.VeCuzCourseMapper;
import org.edu.modules.course.service.IVeCuzCourseService;
import org.edu.modules.course.vo.VeCuzCourseVo;
import org.edu.modules.liancategory.entity.VeCuzCourseCategory;
import org.edu.modules.liancategory.service.IVeCuzCourseCategoryService;
import org.edu.modules.maker.entity.VeCuzCourseMaker;
import org.edu.modules.maker.service.IVeCuzCourseMakerService;
import org.edu.modules.summary.entity.VeCuzCourseSummary;
import org.edu.modules.summary.service.IVeCuzCourseSummaryService;
import org.edu.modules.terminal.service.IVeCuzTerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VeCuzCourseServiceImpl
        extends ServiceImpl<VeCuzCourseMapper, VeCuzCourse>
        implements IVeCuzCourseService
{
    @Autowired
    VeCuzCourseMapper veCuzCourseMapper;
    @Autowired
    IVeCuzTerminalService veCuzTerminalService;
    @Autowired
    IVeCuzCourseCategoryService veCuzCourseCategoryService;
    @Autowired
    IVeCuzCourseMakerService veCuzCourseMakerService;
    @Autowired
    IVeCuzCourseSummaryService veCuzCourseSummaryService;

    public IPage<Map<String, Object>> coursePageMaps(Page<Map<String, Object>> page, QueryWrapper<VeCuzCourse> queryWrapper)
    {
        return ((VeCuzCourseMapper)getBaseMapper()).selectCourseMapsPage(page, queryWrapper);
    }

    public boolean save(VeCuzCourse veCuzCourse, VeCuzCourseSummary veCuzCourseSummary, VeCuzCourseCategory veCuzCourseCategory, VeCuzCourseMaker veCuzCourseMaker)
    {
        this.veCuzCourseCategoryService.saveCate(veCuzCourseCategory);
        this.veCuzCourseMakerService.saveMaker(veCuzCourseMaker);
        this.veCuzCourseSummaryService.saveSummary(veCuzCourseSummary);

        return this.veCuzCourseMapper.insert(veCuzCourse) > 0;
    }

    public IPage<Map<String, Object>> myCreatPageMaps(Page<Map<String, Object>> page, QueryWrapper<VeCuzCourse> queryWrapper)
    {
        return ((VeCuzCourseMapper)getBaseMapper()).myCreatPageMaps(page, queryWrapper);
    }

    public IPage<Map<String, Object>> unFinishPageMaps(Page<Map<String, Object>> page, QueryWrapper<VeCuzCourse> queryWrapper)
    {
        return ((VeCuzCourseMapper)getBaseMapper()).unFinishPageMaps(page, queryWrapper);
    }

    public List<VeCuzCourseVo> finishedPageMaps(VeCuzCourseVo veCuzCourseVo, Integer pageSize, Integer pageNo)
    {
        Page page = new Page(pageNo.intValue(), pageSize.intValue(), false);
        Page<VeCuzCourseVo> pageList = ((VeCuzCourseMapper)this.baseMapper).finishedPageMaps(page, veCuzCourseVo);
        return pageList.getRecords();
    }
}
